// 根据传递的 icon 名，来设置一个 icon 图标；
// 根据项目生成映射关系

<template>
  <i class="iconfont" :class="iconName"></i>
</template>

<script>
// 形成 类名 和 通用名 的映射
const ClassMap = {
  home: "iconzhuye",
  success: "iconzhengque",
  error: "iconcuowu",
  close: "iconguanbi",
  warn: "iconjinggao",
  info: "iconxinxi",
  blog: "iconblog",
  code: "iconcode",
  about: "iconset_about_hov",
  weixin: "iconweixin",
  mail: "iconemail",
  github: "icongithub",
  qq: "iconsign_qq",
  arrowUp: "iconiconfonticonfonti2copy",
  arrowDown: "iconiconfonticonfonti2",
  empty: "iconempty",
  chat: "iconliuyan",
};
export default {
  props: {
    type: {
      type: String,
      required: true,
    },
  },
  computed: {
    iconName() {
      return ClassMap[this.type];
    },
  },
};
</script>

<style lang="less" scoped>
// 引入字体图标库
@import url("//at.alicdn.com/t/font_2164449_nalfgtq7il.css");
.iconfont {
  color: inherit;
  font-size: inherit;
}
</style>